<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>诉讼记录基础信息 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="诉讼记录" lselected="true">
            <div class="searchArea" id="addBtnDiv">
                <span id="addBtn" class="sq-button sq-button-round">添加诉讼记录</span>
            </div>
            <div id="ligergrid1" class="sq-grid"></div>
            <div id="ligergrid2" class="sq-grid"></div>
        </div>
        <div tabid="tabB" title="诉讼申请单" lselected="true">
            <iframe frameborder="0" id="cstRskSign" name="cstRskSign"></iframe>
        </div>

    </div>
</div>

<script type="text/javascript">

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    // 格式化生效时间
    function renderDate4EffectTm(rowdata, index, value) {
        var dateStr = "";
        if (null != rowdata) {
            var date = new Date(rowdata);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    var pageInApp = {}; // to 下一级子窗口 接口
    var pageInTab = null;
    var grid = null;
    var addFlag = '${addFlag}';
    var applyId = '${applyId}';
    $(function () {
        initTab();
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/sue/sueBscInfo/initList.do?applyId=' + applyId,
            method: 'get',
            columns: [
                {
                    display: '创建时间', name: 'crtTm', minWidth: 60, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        return renderDate(rowdata, rowindex, value);
                    }
                },
                {display: '创建人', name: 'crtUsrNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '管辖法院', name: 'courtNm', minWidth: 60, align: 'center', enabledSort: false},
                {
                    display: '立案时间', name: 'registTm', minWidth: 100, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        return renderDate(rowdata, rowindex, value);
                    }
                },
                {display: '案件号', name: 'caseNo', minWidth: 80, align: 'center', enabledSort: false},
                {
                    display: '开庭时间', name: 'courtTm', minWidth: 80, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        return renderDate(rowdata, rowindex, value);
                    }
                },
                {display: '诉讼进度', name: 'processNm', minWidth: 80, align: 'center', enabledSort: false},
                {
                    display: '判决时间', name: 'judgeTm', minWidth: 80, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        return renderDate(rowdata, rowindex, value);
                    }
                },
                {
                    display: '生效时间', name: 'effectTm', minWidth: 160, align: 'center', enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        if ((null != rowdata.effectStTm) && (null != rowdata.effectEdTm)) {
                            return renderDate4EffectTm(rowdata.effectStTm, rowindex, value) + ' ~ ' + renderDate4EffectTm(rowdata.effectEdTm, rowindex, value);
                        }
                    }
                },
                {display: '执行状态', name: 'caseRstNm', minWidth: 80, align: 'center', enabledSort: false},
                {
                    display: '查看资料',
                    name: 'caseRstNm',
                    minWidth: 140,
                    align: 'center',
                    enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        var h = '';
                        h += '<a href="javascript:showSueFiles(';
                        h += "'" + rowdata.id + "'";
                        h += ",'SUE_BSC_INFO'";
                        h += ')">诉讼资料</a>';
                        return h;
                    }

                },
                {display: '其他说明', name: 'sueRem', minWidth: 160, align: 'center', enabledSort: false},
                {
                    display: '操作',
                    name: 'caseRstNm',
                    minWidth: 140,
                    align: 'center',
                    enabledSort: false,
                    render: function (rowdata, rowindex, value) {
                        var h = '';
                        h += '<a href="javascript:showSueDetail(';
                        h += "'" + applyId + "'";
                        h += ",'"+rowdata.id + "'";
                        h += ')">查看诉讼记录详情</a>';
                        return h;
                    }
                }
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        /* 添加诉讼记录 */
        $("#addBtn").click(function (event) {
            var prjId = "${prjId}";
            var url = '<%=path%>/sue/sueBscInfo/toAddPage.do?applyId=' + applyId;
            var title = '添加诉讼记录';
            $.ligerDialog.open({
                width: 1200,
                height: 600,
                title: title,
                url: url
            });
        });

        if (addFlag === 'false') {
            $("#addBtnDiv").hide();
        } else if (addFlag === 'true') {
            $("#addBtnDiv").show();
        }

    });

    var loadedTabs = [];
    //初始化Tab页签
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                var selectedRows = grid.getSelectedRows();
                //var projectId = $("#projectId").val();
                if (tabid != "tabA" && tabid != "tabB") {
                    if (selectedRows.length != 1) {
                        $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                loadedTabs.push(tabid);
                switch (tabid) {
                    case "tabA":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/sue/sueBscInfo/initList.do?applyId=" + applyId);
                        break;
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/sue/sueApplyInfo/toAddPage.do?applyId=${applyId}&viewFlag=1");
                        break;
                }

                SetIframe_height();
            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    };

    function showSueFiles(id, tableNm) {
        var url = '<%=path%>/sue/sueBscInfo/toSueFilePage.do?id=' + id + '&tableNm=' + tableNm;
        var title = '查看诉讼资料';
        $.ligerDialog.open({
            width: 1200,
            height: 600,
            title: title,
            url: url
        });
    }
    /* 查看诉讼记录详情 */
    function showSueDetail(applyId, id) {
        var url = '<%=path%>/sue/sueBscInfo/toSueDetail.do?applyId=' + applyId + '&id=' + id;
        var title = '查看诉讼记录详情';
        $.ligerDialog.open({
            width: 1200,
            height: 600,
            title: title,
            url: url
        });
    };

</script>

</body>
</html>
